package com.qf.handler;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * Spring官方提供的一个后处理器  全局：expression="execution(* *(..))
 *
 *  切入点：初始化方法
 *
 * @author lixu
 */
public class MyBeanPostProcessor implements BeanPostProcessor {

    /**
     * 初始化之前
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("MyBeanPostProcessor====初始化之前");
        return null;
    }

    /**
     * 初始化之后
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("MyBeanPostProcessor====初始化之后");
        return null;
    }
}
